package com.jic.market.common.util;

import com.jic.market.model.LoginUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author guohuayong
 * @date: 2020年01月15日
 */
@Service
public class LoginService {
    @Autowired
    private RedisService redisService;

    public LoginUser getCurrentLoginUser(){
        String token = HttpServletUtil.getRequest().getHeader("token");
        System.out.println(token);

        System.out.println(redisService.getValue(token));

        LoginUser loginUser = redisService.getObject(token, LoginUser.class);
        if (loginUser == null) {
            throw new RuntimeException("未登录");
        }

        return loginUser;
    }
}
